package cn.tedu.mall.front.service.impl;

import cn.tedu.mall.common.exception.CoolSharkServiceException;
import cn.tedu.mall.common.restful.ResponseCode;
import cn.tedu.mall.front.mapper.FrontSpuDetailMapper;
import cn.tedu.mall.front.service.IFrontSpuDetailService;
import cn.tedu.mall.pojo.product.vo.SpuDetailStandardVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class FrontSpuDetailServiceImpl implements IFrontSpuDetailService {
    @Autowired
    private FrontSpuDetailMapper spuDetailMapper;

    @Override
    public SpuDetailStandardVO getSpuDetail(Long id) {
        SpuDetailStandardVO spuDetailStandardVO =
                spuDetailMapper.selectSpuDetailBySpuId(id);
        if (spuDetailStandardVO == null) {
            throw new CoolSharkServiceException
                    (ResponseCode.NOT_FOUND, "当前spu没有任何详情");
        }
        return spuDetailStandardVO;
    }
}
